<?php
namespace App\Services;

use App\Models\Hero;

class PositionService {
    static $cache_key = 'position';

    public static function get() {
        return \Cache::tags(Hero::class)->rememberForever(self::$cache_key, function () {
            $arr = [];
            foreach (['area', 'row',  'seat'] as $type) {
                $list = Hero::select([$type])->whereNotNull($type)->groupBy($type)->get()->pluck($type)->toArray();
                sort($list, 1);
                $arr[$type] = $list;
            }
            return $arr;
        });
    }
}